package com.nexus.all.mongodb.service.impl;

import com.nexus.all.mongodb.model.MongoNoteHistory;
import com.nexus.all.mongodb.repository.NoteHistoryRepository;
import com.nexus.all.mongodb.service.MongoNoteHistoryService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@AllArgsConstructor
@Slf4j
public class MongoNoteHistoryServiceImpl implements MongoNoteHistoryService {

    private final NoteHistoryRepository noteHistoryRepository;

    @Override
    public void dealNoteBrowseNum() {
        List<MongoNoteHistory> mongoNoteHistoryList = noteHistoryRepository.findAll();
        noteHistoryRepository.deleteAll();
        for (MongoNoteHistory mongoNoteHistory : mongoNoteHistoryList) {
            //TODO 同步保存入库逻辑
            log.info("笔记浏览量 笔记id:{},浏览量:{}", mongoNoteHistory.getNoteId(), mongoNoteHistory.getBrowseNum());
        }
    }
}
